import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: a
 * Date: 2022-07-17
 * Time: 19:51
 */
public class JDBC_TestDemo {
    public static void main(String[] args) throws SQLException {
        DataSource dataSource=new MysqlDataSource();
        ((MysqlDataSource)dataSource).setUrl("jdbc:mysql://127.0.0.1:3306/test?characterEncoding=utf8&useSSL=false");
        ((MysqlDataSource)dataSource).setUser("root");
        ((MysqlDataSource)dataSource).setPassword("123456");

        Connection connection= dataSource.getConnection();

        //增
        JDBC_Insert jdbcInsert=new JDBC_Insert();
        jdbcInsert.Insert(connection);

        //改
        JDBC_Update jdbcUpdate=new JDBC_Update();
        jdbcUpdate.Update(connection);

        //查
        JDBC_Select jdbcSelect=new JDBC_Select();
        jdbcSelect.Select(connection);

        //删
        JDBC_Delete jdbcDelete=new JDBC_Delete();
        jdbcDelete.Delete(connection);
    }
}
